﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Exhibition.RenderTemplete.Controls;
using Exhibition.Common.Helper;
using Exhibition.Service; 

namespace Exhibition.Manage
{
    public partial class SiteEndTime : BaseAdminPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (CurrentSite.Id == 0)
                {
                    JsHelper.Alert(this, CommFunMsg.GetMessage("s0001", Lan.zh));
                    return;
                }
                else
                {
                    txtEndDate.Value = CurrentSite.EndTime == null ? "" : Convert.ToDateTime(CurrentSite.EndTime).ToString("yyyy-MM-dd");
                }
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtEndDate.Value))
            {
                CurrentSite.EndTime = Convert.ToDateTime(txtEndDate.Value);

                if (CenterService.siteService.Save(CurrentSite) > 0)
                {
                    JsHelper.Alert(this, CommFunMsg.GetMessage("a0001", Lan.zh));
                    return;
                }
            }
            else
            {
                JsHelper.Alert(this, CommFunMsg.GetMessage("a0002", Lan.zh));
                return;
            }
        }
    }
}